package com.hertz.iris.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hertz.iris.R;

public class MyAdapter extends BaseAdapter{

	private Context context;
	private String[] strs = null;
	LayoutInflater inflater = null;
	public MyAdapter(Context context){
		this.context = context;
		//listview中循环显示的数据
		strs = new String[]{"0","1","2","3","4","5","6","7","8","9"};
		inflater = LayoutInflater.from(context);
	}
	public MyAdapter(){
		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		//返回int可以保存的最大值，此值为2147483647
		return Integer.MAX_VALUE;
	}
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public View getView(int position, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if(view == null){
			holder = new ViewHolder();
			view = inflater.inflate(R.layout.simple_list_item_1, null);
			holder.text = (TextView) view.findViewById(android.R.id.text1);
			view.setTag(holder);
		}else{
			holder = (ViewHolder) view.getTag();
		}
		//strs[position%strs.length]实现listview中数据的循环
		holder.text.setText(strs[position%strs.length]);
		
		return view;
	}
	
}

class ViewHolder{
	public TextView text;
}


